<template>
	<form bindsubmit="savePersonInfo">
	    <view class="form-list">
	        <view class="form-item">
	            <view class="form-item-hd">昵称:</view>
	            <view class="form-item-bd">
	                <input type="text" v-model="nikeName" placeholder="请输入昵称" maxlength="8"/>
	            </view>
	        </view>
	    </view>
	        <view class="form-item">
	            <view class="form-item-hd">手机号码:</view>
	            <view class="form-item-bd">
	                <input type="number" v-model="tel" placeholder="请输入手机号码" maxlength="11"/>
	            </view>
	        </view>
	    </view>
	    <view class="form-list">
	        <view class="form-item">
	            <view class="form-item-hd">地址</view>
	            <view class="form-item-bd">
	                <input type="text" v-model="prov" placeholder="请输入地址" maxlength="25"/>
	            </view>
	        </view>
	    </view>
	    <button @click="editMessage(openid,prov,tel,nikeName)" class="edit-btn">保 存</button>
	</form>
</template>

<script>
	
export default {
		data() {
			return {
				openid: '',
				tel: '',
				prov:'',
				nikeName:''
			}
		},
		onLoad(option) { //option为object类型，会序列化上个页面传递的参数
			console.log(option.openid); //打印出上个页面传递的参数。
			this.openid = option.openid;
		},
		methods: {
		
			editMessage(openid,prov,tel,nikeName) {
				console.log(openid);
				console.log(nikeName);
				this.$axios({
					method: 'post',
					url: '/editMessage/' + this.openid,
					params: { prov:prov,telephone:tel,nikeName:nikeName }

				}).then(res => {
					this.openid = res.data;

				}).catch(err => {
					console.log(err)
				})
				setTimeout(function() {
					uni.showToast({
						title: "编辑成功!"
					});
					setTimeout(function () {
					     //要延时执行的代码
						uni.reLaunch({
							url:'/pages/my/my'
						})
					    }, 1000) //延迟时间 这里是1秒
				}, 1000)
			}
		}
	}
	
</script>

<style>
	.form-list {
	    position: relative;
	    margin-bottom: 20rpx;
	}
	
	.form-list:first-child {
	    margin-top: 20rpx;
	}
	
	.form-list::before, .form-list::after {
	    content: '';
	    display: block;
	    position: absolute;
	    left: 0;
	    height: 1px;
	    width: 100%;
	    transform: scaleY(.5);
	    background-color: #e3e3e3;
	}
	
	.form-list::before {
	    top: 0;
	}
	
	.form-list::after {
	    bottom: 0;
	}
	
	.form-item {
	    position: relative;
	    box-sizing: border-box;
	    display: flex;
	    width: 100%;
	    padding: 15rpx 40rpx;
	}
	
	.form-item::before {
	    content: '';
	    display: block;
	    position: absolute;
	    z-index: 99;
	    left: 0;
	    top: 0;
	    height: 1px;
	    width: 100%;
	    transform: scaleY(.5);
	    background-color: #e3e3e3;
	}
	
	.form-item:first-child::before {
	    display: none;
	}
	
	.form-item-hd {
	    width: 150rpx;
	    height: 60rpx;
	    line-height: 60rpx;
	}
	
	.form-item-bd {
	    flex: 1;
	    height: 60rpx;
	}
	
	input, .input {
	    box-sizing: border-box;
	    width: 100%;
	    height: 60rpx;
	    line-height: 60rpx;
	    background-color: #fff;
	    padding: 0 15rpx;
	}
	
	.input-placeholder {
	    color: #808080;
	}
	
	.edit-btn {
	    width: 300rpx;
	    height: 80rpx;
	    margin: 0 auto;
	    font-size: 32rpx;
	    text-align: center;
	    line-height: 80rpx;
	    background-color: #47a86c;
	    border-radius: 80rpx;
	    color: #fff;
	}
	
	.hidden {
	    display: none;
	}
</style>